<template>
  <div class="form_box">
    <p>邮箱登录</p>
    <el-form :model="form" ref="Form" label-width="50px" class="form">
      <el-form-item
        prop="mobile"
        label="账号"
      >
        <el-input class="input" v-model="form.mobile"></el-input>
      </el-form-item>
      <el-form-item
        prop="pwd"
        label="密码"
      >
        <el-input class="input" type="password" v-model="form.pwd"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button class="login" type="primary" @click="gologin()">登录</el-button>
      </el-form-item>
      <div class="btns">
        <router-link class="regist" to='/regist'>用户注册</router-link>
        <router-link class="forget" to='/forget'>忘记密码</router-link>
      </div>
    </el-form>
  </div>
</template>

<script>
import { login } from '../../apis/api.js'
import { storage } from '../../utils/storage.js'
export default {
  data() {
    return {
      form: {
        mobile: '13523025110',
        pwd: '123456'
      }
    }
  },
  methods: {
    gologin() {
      console.log(this.form)
      // storage.setSession('token', '123456')
      // this.$router.push('/')
      // this.$message.success('登陆成功')
      login(this.form).then(res => {
        storage.setSession('token', res.token)
        storage.setSession('id', res.id)
        storage.setSession('nick', res.nick)
        storage.setSession('mobile', res.mobile)
        this.$message.success('登陆成功')
        setTimeout(() => {
          this.$router.push('/')
        }, 500)
      })
    }
  }
}
</script>

<style scoped>
  .form_box {
    max-width: 350px;
    margin: 80px auto 0;
    overflow: hidden;
    padding: 5px 30px 5px 25px;
    background: rgba(255, 255, 255, .3);
    border-radius: 20px;
  }
  .form_box {
    padding-bottom: 25px;
  }
  .form_box>p {
    font-size: 18px; font-weight: 600; margin-bottom: 40px;
  }
  /* .input {
    background: url(../../assets/table.png)
  } */
  .login {
    width: 200px;
  }
  .btns {
    display: flex;
    justify-content: space-between;
    line-height: 20px;
  }
  a {
    font-size: 14px;
    color: #797464;
    text-decoration: none;
  }
  a:hover {
    color: #959081;
    text-decoration: underline;
  }
</style>
